﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="DataLayer" namespace="DataLayer.Entities">
  <class name="ArtistEntity" table="artists" lazy="false">
    <id name="ID" column="id">
      <generator class="native" />
    </id>
    <property name="Name" column="name" not-null="true"/>
    <property name="PrivateMarks" column="private_marks"/>
    <property name="Biography" column="biography"/>

    <!--Owns relation and persists bindings into artists_albums table-->
    <bag name="Albums" table="artists_albums" lazy="true">
      <key column="artist_id"/>
      <many-to-many column="album_id"
         class="DataLayer.Entities.AlbumEntity, NHibernateManyToMany"/>
    </bag>

    <bag name="Tags" table="tags_artists" lazy="true">
      <key column="artist_id"/>
      <many-to-many column="tag_id"
         class="DataLayer.Entities.TagEntity, NHibernateManyToMany"/>
    </bag>
  </class>
</hibernate-mapping>